/**模块：系统通用
 *
 * reducer
 *
 * 它是一个对不同action做出不同操作的函数。
 *
 * 不直接去改变state的值，而是返回一个新的state。
 *
 */

import * as actionType from './action-type';

interface ActionType {
  type: string;
  [key: string]: any;
}
/** uniqueToken */
export const uniqueToken = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_UNIQUE_TOKEN) {
    return action.uniqueToken;
  } else {
    return state;
  }
};
/** encryptToken */
export const encryptToken = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_ENCRYPT_TOKEN) {
    return action.encryptToken;
  } else {
    return state;
  }
};

/** token */
export const token = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_TOKEN) {
    return action.token;
  } else {
    return state;
  }
};
/** 登录信息 */
export const loginInfo = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_LOGIN_INFO) {
    return action.loginInfo;
  } else {
    return state;
  }
};
/** 个人用户信息 */
export const userInfo = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_USER_INFO) {
    return action.userInfo;
  } else {
    return state;
  }
};

/** web配置 */
export const systemConfig = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_SYSTEM_CONFIG) {
    return action.systemConfig;
  } else {
    return state;
  }
};

/** 签入状态 checkInState  */
export const checkInState = (state = 1, action: ActionType) => {
  if (action.type === actionType.SET_CHECK_IN_STATE) {
    return action.checkInState;
  } else {
    return state;
  }
};

/** sip链接参数 uaConfig  */
export const uaConfig = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_UA_CONFIG) {
    return action.uaConfig;
  } else {
    return state;
  }
};

/** 工作台workspaceInfo的值  */
export const workspaceInfo = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_WORKSPACE_INFO) {
    return action.workspaceInfo;
  } else {
    return state;
  }
};

/** 存储当前人工监听callId  */
export const manListenCallId = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_MANLISTEN_CALLID) {
    return action.manListenCallId;
  } else {
    return state;
  }
};

/** 坐席自动接听开关，on-开启，off-取消  */
export const autoAnswer = (state = 'off', action: ActionType) => {
  if (action.type === actionType.SET_AUTO_ANSWER) {
    return action.autoAnswer;
  } else {
    return state;
  }
};
/** 坐席小休开关，on-开启，off-取消  */
export const seatRest = (state = 'off', action: ActionType) => {
  if (action.type === actionType.SET_SEAT_REST) {
    return action.seatRest;
  } else {
    return state;
  }
};
/** 根据screenNum，设置弹屏box窗口  */
export const screenNum = (state = 1, action: ActionType) => {
  if (action.type === actionType.SET_SCREEN_NUM) {
    return action.screenNum;
  } else {
    return state;
  }
};
/** 设置录音模版Id  */
export const soundTemplateId = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_SOUND_TEMPLATE_ID) {
    return action.soundTemplateId;
  } else {
    return state;
  }
};
/** 新建任务表单缓存 {}  */
export const addTaskFormData = (state = {}, action: ActionType) => {
  if (action.type === actionType.SET_ADD_TASK_FORM_DATA) {
    return action.addTaskFormData;
  } else {
    return state;
  }
};

/** 机器人外呼任务正在被截听的通话Id  */
export const interceptCallId = (state = '', action: ActionType) => {
  if (action.type === actionType.SET_INTERCEPT_CALL_ID) {
    return action.interceptCallId;
  } else {
    return state;
  }
};
